from ChatGLM3本地化部署.util_tools import *
from rank_bm25 import BM25Okapi
import numpy as np

files_names = find_txt_files('../alltxt')
query = "2020年工商银行境内优先股工行优1的股息是多少？"
bm25 = BM25Okapi(files_names)
scores = bm25.get_scores(query)
most_similar_index = np.where(scores == max(scores))[0][0] #scores.index(max(scores))
most_similar_file = files_names[most_similar_index]
print("quey:{}".format(query))
print("similar file:{}".format(most_similar_file))
